<template>
	<view class="newpeople" v-if="show" @click="_go">
		<view class="cntbox">
			<image class="close" @click.stop="_close" src="../../static/image/common/close.png" mode="widthFix"></image>
			<image class="cnttitimg" src="../../static/image/newpeople/np1.png" mode="widthFix"></image>
			<view class="cnt">
				<image class="cnt_bg" src="../../static/image/newpeople/newp_bg.png" mode="widthFix"></image>
				<view class="cnt_">
					<view class="tit">新人好物只要1分钱</view>
					<view class="box">
						<view class="item" v-for="(item,index) in noviceZoneList" :key="index">
							<view class="imgbox">
								<image :src="item.cover" mode=""></image>
							</view>
							<view class="price_txt"><text class="y">¥</text>{{item.selling_price}}</view>
						</view>
					</view>
					<view class="btn">立即购买</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		topicList,
		topicGoodsList,
		setShowNewStatus
	} from '@/api/index/index'
	import {
		mapState
	} from 'vuex'
	export default {
		name: "newpeople",
		data() {
			return {
				noviceZoneList: [],
				show: false
			}
		},
		computed: {
			...mapState(["userinfo"])
		},
		watch: {
			userinfo: {
				handler(val) {
					this.show = val.is_show_new == 1
				},
				deep: true,
				immediate: true
			}
		},
		mounted() {
			this.noviceZone();
		},
		methods: {
			/* 获取新手专区数据 取前三个*/
			noviceZone() {
				topicList({
					type: 1
				}).then(({
					data
				}) => {
					topicGoodsList({
						id: data[0].id,
						page: 1,
						page_size: 3
					}).then(({
						data: {
							list
						}
					}) => {
						this.noviceZoneList = list;
					})
				}).catch(err => {
					console.log(err)
				})
			},
			_close() {
				this.show = false;
				setShowNewStatus();
			},
			_go() {
				uni.navigateTo({
					url: '/pages/index/free-deposit/free-deposit?title=新人专区&type=1',
					success: () => {
						this._close();
					}
				})
			}
		}
	}
</script>

<style scoped>
	image {
		display: block;
		width: 100%;
		height: 100%;
	}

	.newpeople {
		position: fixed;
		top: 0;
		left: 0;
		z-index: 1000;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, .6);
	}

	.cntbox {
		position: absolute;
		top: 55%;
		left: 0;
		width: 100%;
		height: 806rpx;
		transform: translate(0, -50%);
	}

	.close {
		position: absolute;
		top: -54rpx;
		right: 2.2%;
		width: 54rpx;
		height: 54rpx;
	}

	.cnttitimg {
		display: block;
		width: 618rpx;
		height: 104rpx;
		margin-left: 46rpx;
		margin-bottom: 30rpx;
	}

	.cnt {
		margin: 0 auto;
		width: 94.6%;
		height: 604rpx;
		position: relative;
	}

	.cnt_bg {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 1;
	}

	.cnt_ {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 2;
	}

	.tit {
		margin: 28rpx auto 36rpx;
		letter-spacing: 2rpx;
		text-align: center;
		color: white;
		font-size: 32rpx;
	}

	.box {
		margin: 0 auto;
		width: 94%;
		height: 342rpx;
		background-color: white;
		border-radius: 12rpx;
		display: flex;
		justify-content: space-between;
		box-sizing: border-box;
		padding: 26rpx 20rpx;
	}

	.item {
		width: 30.3%;
		height: 100%;
		text-align: center;
		color: #F54642;
	}

	.imgbox {
		width: 100%;
		height: 240rpx;
		background-color: gray;
	}

	.price_txt {
		margin: 16rpx auto 0;
		font-size: 34rpx;
	}

	.price_txt .y {
		font-size: 20rpx;
	}

	.btn {
		margin: 40rpx auto 0;
		width: 78.6%;
		height: 74rpx;
		line-height: 74rpx;
		text-align: center;
		background: #FFEEE2;
		border-radius: 38rpx;
		color: #A36C2B;
		font-size: 32rpx;
	}
</style>
